import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'amfe-flexible'
import less from 'less'
import Vant from 'vant'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import moment from 'moment'

Vue.filter('formatDate', (input, formatString = "YYYY-MM-DD HH:mm:ss") => {
   if(!input){
     return '-'
   }
       //es5函数参数设置默认值
       //const lastFormatString = formatString || ''
       // moment(input) 把时间字符串转成时间对象
       // format(formatString) 把时间对象，按照指定格式，格式化成符合条件的字符串
       return moment(input).format(formatString)
   })
 Vue.prototype.moment  =  moment; 
Vue.use(ElementUI);



// import 'vant/lib/vant-css/index.css'
Vue.use(Vant)
Vue.use(less)
Vue.config.productionTip = false

// 登录拦截
router.beforeEach((to, from, next) => {
  if (to.path == '/') {
    sessionStorage.removeItem('shopId');
  }
    let shopId = sessionStorage.getItem('shopId')
    if (!shopId&&to.path != '/') {
      next({ path: '/' })
    } else{
      next()
    }
})





new Vue({
  router,
  store,
  render: function (h) { return h(App) }
}).$mount('#app')
